package com.cainaer.product.controller;


import com.cainaer.common.core.web.controller.BaseController;
import com.cainaer.common.core.web.domain.AjaxResult;
import com.cainaer.product.domain.ProductAttributeOption;
import com.cainaer.product.service.IProductAttributeOptionService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统属性表 前端控制器
 * </p>
 *
 * @author Tina
 * @since 2020-09-11
 */
@RestController
@RequestMapping("/productAttributeOption/")
public class ProductAttributeOptionController extends BaseController {

    @Autowired
    private IProductAttributeOptionService productAttributeOptionService;

    /**
     * 查询商品属性
     *
     * @return
     */
    @GetMapping("list")
    public AjaxResult selectProductAttributeOption() {

        return AjaxResult.success(productAttributeOptionService.selectProductAttributeOption(null));
    }

    /**
     * 新增商品属性
     *
     * @param productAttributeOption
     * @return
     */
    @PostMapping("add")
    public AjaxResult insertProductAttributeOption(ProductAttributeOption productAttributeOption) {
        return toAjax(productAttributeOptionService.insertProductAttributeOption(productAttributeOption));
    }

    /**
     * 编辑商品属性
     *
     * @param productAttributeOption
     * @return
     */
    @PostMapping("edit")
    public AjaxResult editProductAttributeOption(ProductAttributeOption productAttributeOption) {
        return toAjax(productAttributeOptionService.editProductAttributeOption(productAttributeOption));
    }

    /**
     * 查询商品默认属性
     *
     * @return
     */
    @GetMapping("selectProductAttributeOrOption")
    public AjaxResult selectProductAttributeOrOption(Long productId) {

        return AjaxResult.success(productAttributeOptionService.selectProductAttributeOrOption(productId));
    }

}
